<?php
// +--------------------------------------------------------------------------
// | ZAIYOUDAO [ 载攸道 先顺得常 ] <http://www.zaiyoudao.com>
// +--------------------------------------------------------------------------
// | Copyright © 2009-2016 载攸道 版权所有 <TEL:17090888854>
// +--------------------------------------------------------------------------
// | Project: YiPHP [ 我会的仅仅是偷懒！ ] <http://www.yiphp.com>
// +--------------------------------------------------------------------------
// | Author: 牛很多戒很多不戒 <n@isdce.com> <http://juexue.wang>
// +--------------------------------------------------------------------------

/**
 * 微信扩展插件
 */
namespace Addon\WeiXin\Controller;
use Addon\WeiXin\Controller\CommonController;

/**
 * 微信公共插件
 */
class OAuthController extends CommonController {
    

	//登录授权
	public function Login(){
		
		//获得授权登录
		$callback = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['SERVER_NAME'].'/Home/Public/Login/Addon/WeiXin.html';
		
		$weixin = getWeiXinConf();
		$url = \Org\Net\Wechat\Oauth::url($weixin['weixinpay_appid'],$callback,'1','snsapi_userinfo');
		
		redirect("$url", 0,'');
				
		
	}
	
	//支付授权
	public function Pay(){
		
		//支付对应订单号
		$id = I('param.id');
		//获得支付地址
		$callback = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['SERVER_NAME']."/Home/Pay/Order/Addon/WeiXin.html?id=$id";
		$weixin = getWeiXinConf();
		$url = \Org\Net\Wechat\Oauth::url($weixin['weixinpay_appid'],$callback,'2');
		
		redirect("$url", 0,'');
				
		
	}
	
	
	//地址授权
	public function Address(){
		
		//获得地址
		$callback = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['SERVER_NAME']."/Home/Address/Manage/Addon/Mall.html";
		$weixin = getWeiXinConf();
		$url = \Org\Net\Wechat\Oauth::url($weixin['weixinpay_appid'],$callback,'3');
		
		redirect("$url", 0,'');
				
	}
	
	
	
	
}